<?php
try{
	require('connect.php');
	$pdo->query("set names utf8");
	if(isset($_GET['type']))
	{
		$type = $_GET['type'];
		if($type == 'content')
		{
			$query = "select * from wall where wall_delete = 0 order by wall_id desc";
			$result = $pdo -> query($query);
			$wallArray = array();
			foreach( $result as $row ){
				$wallArray[]=$row;
			}
			//print_r($wallArray);
		    $infoJson = json_encode($wallArray);
		    echo $infoJson;
		}
	}
	if(isset($_POST['login']))
	{
		$psw = $_POST['psw'];
		$un = $_POST['un'];
		//$psw = '123456';
		//$un = 'admin';
		$query = 'select * from user where user_name = ? and user_pw = ?';
		$result = $pdo -> prepare($query);
		$result -> bindParam(1,$un);
		$result -> bindParam(2,$psw);
		$result -> execute();
		if($result->columnCount())
		{
			$userInfo = array();
			foreach( $result as $row ){
				$userInfo['user_name']=$row['user_name'];
				$userInfo['user_nick']=$row['nickname'];
			}
			echo json_encode($userInfo);
		}
		else
			echo json_encode(FALSE);
	}

}catch(PDOException $e){
	echo"连接数据库失败！".$e->getMessage();
}
